Optimal. Leaf size=117 \[ \frac {a^2 \tanh ^{-1}(\sin (e+f x))}{d^2 f}-\frac {2 a^2 \sqrt {c-d} (c+2 d) \tanh ^{-1}\left (\frac {\sqrt {c-d} \tan \left (\frac {1}{2} (e+f x)\right )}{\sqrt {c+d}}\right )}{d^2 (c+d)^{3/2} f}-\frac {a^2 (c-d) \tan (e+f x)}{d (c+d) f (c+d \sec (e+f x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.17, antiderivative size = 231, normalized size of antiderivative = 1.97, number of steps
used = 8, number of rules used = 8, integrand size = 31, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.258, Rules used = {4072, 100, 163,
65, 223, 209, 95, 211} \begin {gather*} \frac {2 a^3 \sqrt {c-d} (c+2 d) \tan (e+f x) \text {ArcTan}\left (\frac {\sqrt {c+d} \sqrt {a \sec (e+f x)+a}}{\sqrt {c-d} \sqrt {a-a \sec (e+f x)}}\right )}{d^2 f (c+d)^{3/2} \sqrt {a-a \sec (e+f x)} \sqrt {a \sec (e+f x)+a}}+\frac {2 a^3 \tan (e+f x) \text {ArcTan}\left (\frac {\sqrt {a-a \sec (e+f x)}}{\sqrt {a (\sec (e+f x)+1)}}\right )}{d^2 f \sqrt {a-a \sec (e+f x)} \sqrt {a \sec (e+f x)+a}}-\frac {a^2 (c-d) \tan (e+f x)}{d f (c+d) (c+d \sec (e+f x))} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 65
Rule 95
Rule 100
Rule 163
Rule 209
Rule 211
Rule 223
Rule 4072
Rubi steps
\begin {align*} \int \frac {\sec (e+f x) (a+a \sec (e+f x))^2}{(c+d \sec (e+f x))^2} \, dx &=-\frac {\left (a^2 \tan (e+f x)\right ) \text {Subst}\left (\int \frac {(a+a x)^{3/2}}{\sqrt {a-a x} (c+d x)^2} \, dx,x,\sec (e+f x)\right )}{f \sqrt {a-a \sec (e+f x)} \sqrt {a+a \sec (e+f x)}}\\ &=-\frac {a^2 (c-d) \tan (e+f x)}{d (c+d) f (c+d \sec (e+f x))}+\frac {(a \tan (e+f x)) \text {Subst}\left (\int \frac {-2 a^3 d-a^3 (c+d) x}{\sqrt {a-a x} \sqrt {a+a x} (c+d x)} \, dx,x,\sec (e+f x)\right )}{d (c+d) f \sqrt {a-a \sec (e+f x)} \sqrt {a+a \sec (e+f x)}}\\ &=-\frac {a^2 (c-d) \tan (e+f x)}{d (c+d) f (c+d \sec (e+f x))}-\frac {\left (a^4 \tan (e+f x)\right ) \text {Subst}\left (\int \frac {1}{\sqrt {a-a x} \sqrt {a+a x}} \, dx,x,\sec (e+f x)\right )}{d^2 f \sqrt {a-a \sec (e+f x)} \sqrt {a+a \sec (e+f x)}}+\frac {\left (a \left (-2 a^3 d^2+a^3 c (c+d)\right ) \tan (e+f x)\right ) \text {Subst}\left (\int \frac {1}{\sqrt {a-a x} \sqrt {a+a x} (c+d x)} \, dx,x,\sec (e+f x)\right )}{d^2 (c+d) f \sqrt {a-a \sec (e+f x)} \sqrt {a+a \sec (e+f x)}}\\ &=-\frac {a^2 (c-d) \tan (e+f x)}{d (c+d) f (c+d \sec (e+f x))}+\frac {\left (2 a^3 \tan (e+f x)\right ) \text {Subst}\left (\int \frac {1}{\sqrt {2 a-x^2}} \, dx,x,\sqrt {a-a \sec (e+f x)}\right )}{d^2 f \sqrt {a-a \sec (e+f x)} \sqrt {a+a \sec (e+f x)}}+\frac {\left (2 a \left (-2 a^3 d^2+a^3 c (c+d)\right ) \tan (e+f x)\right ) \text {Subst}\left (\int \frac {1}{a c-a d-(-a c-a d) x^2} \, dx,x,\frac {\sqrt {a+a \sec (e+f x)}}{\sqrt {a-a \sec (e+f x)}}\right )}{d^2 (c+d) f \sqrt {a-a \sec (e+f x)} \sqrt {a+a \sec (e+f x)}}\\ &=\frac {2 a^3 \sqrt {c-d} (c+2 d) \tan ^{-1}\left (\frac {\sqrt {c+d} \sqrt {a+a \sec (e+f x)}}{\sqrt {c-d} \sqrt {a-a \sec (e+f x)}}\right ) \tan (e+f x)}{d^2 (c+d)^{3/2} f \sqrt {a-a \sec (e+f x)} \sqrt {a+a \sec (e+f x)}}-\frac {a^2 (c-d) \tan (e+f x)}{d (c+d) f (c+d \sec (e+f x))}+\frac {\left (2 a^3 \tan (e+f x)\right ) \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\frac {\sqrt {a-a \sec (e+f x)}}{\sqrt {a+a \sec (e+f x)}}\right )}{d^2 f \sqrt {a-a \sec (e+f x)} \sqrt {a+a \sec (e+f x)}}\\ &=\frac {2 a^3 \tan ^{-1}\left (\frac {\sqrt {a-a \sec (e+f x)}}{\sqrt {a+a \sec (e+f x)}}\right ) \tan (e+f x)}{d^2 f \sqrt {a-a \sec (e+f x)} \sqrt {a+a \sec (e+f x)}}+\frac {2 a^3 \sqrt {c-d} (c+2 d) \tan ^{-1}\left (\frac {\sqrt {c+d} \sqrt {a+a \sec (e+f x)}}{\sqrt {c-d} \sqrt {a-a \sec (e+f x)}}\right ) \tan (e+f x)}{d^2 (c+d)^{3/2} f \sqrt {a-a \sec (e+f x)} \sqrt {a+a \sec (e+f x)}}-\frac {a^2 (c-d) \tan (e+f x)}{d (c+d) f (c+d \sec (e+f x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 1.55, size = 312, normalized size = 2.67 \begin {gather*} \frac {a^2 (d+c \cos (e+f x)) \sec ^4\left (\frac {1}{2} (e+f x)\right ) (1+\sec (e+f x))^2 \left (-\left ((d+c \cos (e+f x)) \log \left (\cos \left (\frac {1}{2} (e+f x)\right )-\sin \left (\frac {1}{2} (e+f x)\right )\right )\right )+(d+c \cos (e+f x)) \log \left (\cos \left (\frac {1}{2} (e+f x)\right )+\sin \left (\frac {1}{2} (e+f x)\right )\right )+\frac {2 \left (c^2+c d-2 d^2\right ) \text {ArcTan}\left (\frac {(i \cos (e)+\sin (e)) \left (c \sin (e)+(-d+c \cos (e)) \tan \left (\frac {f x}{2}\right )\right )}{\sqrt {c^2-d^2} \sqrt {(\cos (e)-i \sin (e))^2}}\right ) (d+c \cos (e+f x)) (i \cos (e)+\sin (e))}{(c+d) \sqrt {c^2-d^2} \sqrt {(\cos (e)-i \sin (e))^2}}+\frac {(c-d) d (d \sin (e)-c \sin (f x))}{c (c+d) \left (\cos \left (\frac {e}{2}\right )-\sin \left (\frac {e}{2}\right )\right ) \left (\cos \left (\frac {e}{2}\right )+\sin \left (\frac {e}{2}\right )\right )}\right )}{4 d^2 f (c+d \sec (e+f x))^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.38, size = 157, normalized size = 1.34
method | result | size |
derivativedivides | \(\frac {8 a^{2} \left (\frac {\ln \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )+1\right )}{8 d^{2}}+\frac {\left (c -d \right ) \left (\frac {d \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{\left (c +d \right ) \left (c \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )-d \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )-c -d \right )}-\frac {\left (c +2 d \right ) \arctanh \left (\frac {\left (c -d \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{\sqrt {\left (c +d \right ) \left (c -d \right )}}\right )}{\left (c +d \right ) \sqrt {\left (c +d \right ) \left (c -d \right )}}\right )}{4 d^{2}}-\frac {\ln \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )-1\right )}{8 d^{2}}\right )}{f}\) | \(157\) |
default | \(\frac {8 a^{2} \left (\frac {\ln \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )+1\right )}{8 d^{2}}+\frac {\left (c -d \right ) \left (\frac {d \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{\left (c +d \right ) \left (c \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )-d \left (\tan ^{2}\left (\frac {f x}{2}+\frac {e}{2}\right )\right )-c -d \right )}-\frac {\left (c +2 d \right ) \arctanh \left (\frac {\left (c -d \right ) \tan \left (\frac {f x}{2}+\frac {e}{2}\right )}{\sqrt {\left (c +d \right ) \left (c -d \right )}}\right )}{\left (c +d \right ) \sqrt {\left (c +d \right ) \left (c -d \right )}}\right )}{4 d^{2}}-\frac {\ln \left (\tan \left (\frac {f x}{2}+\frac {e}{2}\right )-1\right )}{8 d^{2}}\right )}{f}\) | \(157\) |
risch | \(-\frac {2 i a^{2} \left (c -d \right ) \left (d \,{\mathrm e}^{i \left (f x +e \right )}+c \right )}{d f \left (c +d \right ) c \left ({\mathrm e}^{2 i \left (f x +e \right )} c +2 d \,{\mathrm e}^{i \left (f x +e \right )}+c \right )}+\frac {\sqrt {\left (c +d \right ) \left (c -d \right )}\, a^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {i \sqrt {\left (c +d \right ) \left (c -d \right )}-d}{c}\right ) c}{\left (c +d \right )^{2} f \,d^{2}}+\frac {2 \sqrt {\left (c +d \right ) \left (c -d \right )}\, a^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}-\frac {i \sqrt {\left (c +d \right ) \left (c -d \right )}-d}{c}\right )}{\left (c +d \right )^{2} f d}-\frac {\sqrt {\left (c +d \right ) \left (c -d \right )}\, a^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i \sqrt {\left (c +d \right ) \left (c -d \right )}+d}{c}\right ) c}{\left (c +d \right )^{2} f \,d^{2}}-\frac {2 \sqrt {\left (c +d \right ) \left (c -d \right )}\, a^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}+\frac {i \sqrt {\left (c +d \right ) \left (c -d \right )}+d}{c}\right )}{\left (c +d \right )^{2} f d}-\frac {a^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}-i\right )}{d^{2} f}+\frac {a^{2} \ln \left ({\mathrm e}^{i \left (f x +e \right )}+i\right )}{d^{2} f}\) | \(353\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F(-2)]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Exception raised: ValueError} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 258 vs.
\(2 (112) = 224\).
time = 1.69, size = 589, normalized size = 5.03 \begin {gather*} \left [\frac {{\left (a^{2} c d + 2 \, a^{2} d^{2} + {\left (a^{2} c^{2} + 2 \, a^{2} c d\right )} \cos \left (f x + e\right )\right )} \sqrt {\frac {c - d}{c + d}} \log \left (\frac {2 \, c d \cos \left (f x + e\right ) - {\left (c^{2} - 2 \, d^{2}\right )} \cos \left (f x + e\right )^{2} - 2 \, {\left (c^{2} + c d + {\left (c d + d^{2}\right )} \cos \left (f x + e\right )\right )} \sqrt {\frac {c - d}{c + d}} \sin \left (f x + e\right ) + 2 \, c^{2} - d^{2}}{c^{2} \cos \left (f x + e\right )^{2} + 2 \, c d \cos \left (f x + e\right ) + d^{2}}\right ) + {\left (a^{2} c d + a^{2} d^{2} + {\left (a^{2} c^{2} + a^{2} c d\right )} \cos \left (f x + e\right )\right )} \log \left (\sin \left (f x + e\right ) + 1\right ) - {\left (a^{2} c d + a^{2} d^{2} + {\left (a^{2} c^{2} + a^{2} c d\right )} \cos \left (f x + e\right )\right )} \log \left (-\sin \left (f x + e\right ) + 1\right ) - 2 \, {\left (a^{2} c d - a^{2} d^{2}\right )} \sin \left (f x + e\right )}{2 \, {\left ({\left (c^{2} d^{2} + c d^{3}\right )} f \cos \left (f x + e\right ) + {\left (c d^{3} + d^{4}\right )} f\right )}}, -\frac {2 \, {\left (a^{2} c d + 2 \, a^{2} d^{2} + {\left (a^{2} c^{2} + 2 \, a^{2} c d\right )} \cos \left (f x + e\right )\right )} \sqrt {-\frac {c - d}{c + d}} \arctan \left (-\frac {{\left (d \cos \left (f x + e\right ) + c\right )} \sqrt {-\frac {c - d}{c + d}}}{{\left (c - d\right )} \sin \left (f x + e\right )}\right ) - {\left (a^{2} c d + a^{2} d^{2} + {\left (a^{2} c^{2} + a^{2} c d\right )} \cos \left (f x + e\right )\right )} \log \left (\sin \left (f x + e\right ) + 1\right ) + {\left (a^{2} c d + a^{2} d^{2} + {\left (a^{2} c^{2} + a^{2} c d\right )} \cos \left (f x + e\right )\right )} \log \left (-\sin \left (f x + e\right ) + 1\right ) + 2 \, {\left (a^{2} c d - a^{2} d^{2}\right )} \sin \left (f x + e\right )}{2 \, {\left ({\left (c^{2} d^{2} + c d^{3}\right )} f \cos \left (f x + e\right ) + {\left (c d^{3} + d^{4}\right )} f\right )}}\right ] \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} a^{2} \left (\int \frac {\sec {\left (e + f x \right )}}{c^{2} + 2 c d \sec {\left (e + f x \right )} + d^{2} \sec ^{2}{\left (e + f x \right )}}\, dx + \int \frac {2 \sec ^{2}{\left (e + f x \right )}}{c^{2} + 2 c d \sec {\left (e + f x \right )} + d^{2} \sec ^{2}{\left (e + f x \right )}}\, dx + \int \frac {\sec ^{3}{\left (e + f x \right )}}{c^{2} + 2 c d \sec {\left (e + f x \right )} + d^{2} \sec ^{2}{\left (e + f x \right )}}\, dx\right ) \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 230 vs.
\(2 (108) = 216\).
time = 0.53, size = 230, normalized size = 1.97 \begin {gather*} \frac {\frac {a^{2} \log \left ({\left | \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) + 1 \right |}\right )}{d^{2}} - \frac {a^{2} \log \left ({\left | \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - 1 \right |}\right )}{d^{2}} + \frac {2 \, {\left (a^{2} c^{2} + a^{2} c d - 2 \, a^{2} d^{2}\right )} {\left (\pi \left \lfloor \frac {f x + e}{2 \, \pi } + \frac {1}{2} \right \rfloor \mathrm {sgn}\left (2 \, c - 2 \, d\right ) + \arctan \left (\frac {c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - d \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )}{\sqrt {-c^{2} + d^{2}}}\right )\right )}}{{\left (c d^{2} + d^{3}\right )} \sqrt {-c^{2} + d^{2}}} + \frac {2 \, {\left (a^{2} c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right ) - a^{2} d \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )\right )}}{{\left (c \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - d \tan \left (\frac {1}{2} \, f x + \frac {1}{2} \, e\right )^{2} - c - d\right )} {\left (c d + d^{2}\right )}}}{f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 4.79, size = 2563, normalized size = 21.91 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________